<%@ page import="java.util.*"%>
<%@ page import="objects.*"%>
<%@ page import="Domain.UserClient.ButtonsFunctions"%>
<%@page import="Domain.DataManager"%>

<%
	DataManager dm = (DataManager) (session.getAttribute("dm"));
	ButtonsFunctions bf = (ButtonsFunctions) (session
			.getAttribute("bf"));

	if (dm == null || dm.getUserStatus() == DataManager.DISCONNECTED) {
		response.sendRedirect("Welcome.jsp");
	} else {
%>

<%
	bf.processGetFriends();
	Vector<User> friends = dm.getVectorFriends();
	
	String nameOfFriend = request.getParameter("nameOfFriend");
%>


<%
    boolean alreadyAFriend = false;
    for (int i = 0; i < friends.size(); i++)
    {
        User user = friends.elementAt(i);
        if(user.getUserName().equals(nameOfFriend))
            alreadyAFriend = true;
    }
    if(!alreadyAFriend)
    {
        bf.processAddFriend(nameOfFriend);
    }
%>

<%
	}
%>
